package me.obstsalatt.guildera2.container;

import me.obstsalatt.guildera2.core.Owner;
import org.bukkit.Chunk;

/**
 * Created with IntelliJ IDEA.
 * User: Robin
 * Date: 13.02.14, 23:21
 * Project: GuildEra2
 * Package: me.obstsalatt.guildera2
 * Descriprion:
 *      A container of the standard chunk
 */
public class GChunk{
    private Chunk c;
    private Owner owner;

    public GChunk(Chunk c) {
        this.c = c;
        this.owner = new Owner();
    }

    public GChunk(Chunk c, Owner owner) {
        this.c = c;
        this.owner = owner;
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        GChunk gChunk = (GChunk) o;

        if (!c.equals(gChunk.c)) return false;
        if (!owner.equals(gChunk.owner)) return false;

        return true;
    }

    public int hashCode() {
        int result = c.hashCode();
        result = 31 * result + owner.hashCode();
        return result;
    }

    public boolean isOwned() {
        return !owner.isDefault();
    }

    public Owner getOwner() {
        return owner;
    }

    public void setOwner(Owner owner) {
        this.owner = owner;
    }

    public Chunk getChunk() {
        return c;
    }
}
